<?php

include 'header.php';

?>
<h4>Please fill out the form to register as a player</h4>

<?php
include 'config.php';
include 'opendb.php';

try{

if(isset($_POST['add']))
{

$name = mysql_real_escape_string($_POST['name'], $conn);
$password = mysql_real_escape_string($_POST['password'], $conn);

$prequery= "SELECT PASSWORD FROM PLAYER WHERE NAME='$name';";
$auth = mysql_fetch_row(mysql_query($prequery, $conn));

$password = md5($password);


if($password == $auth[0]){

	$query= "DELETE FROM PLAYER WHERE NAME='$name';";
	mysql_query($query, $conn);		
				
	echo "<p>Player Deleted</p>";
}
else{

	echo "<p>username/password error</p>";

}


}
else
{
?>
<p>Please fill out the following information to add an employee.</p>
<br>
<form method="post">
<table width="450" border="0" cellspacing="1" cellpadding="2">
<tr>
<td width="200">Name</td>
<td><input name="name" type="text" id="name"></td>
</tr>
<tr>
<td width="200">Password</td>
<td><input name="password" type="password" id="password"></td>
</tr>
<tr>
<td width="200">&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td width="200">&nbsp;</td>
<td><input name="add" type="submit" id="add" value="DELETE"></td>
</tr>
</table>
</form>
<?php
	}

}
catch(Exception $e){

echo  "you fail";

}
?>

<?php

include 'footer.php';

include 'closedb.php';
?>